import { useState } from 'react'
import TaskInput from './components/TaskInput/TaskInput'
import TaskList from './components/TaskList/TaskList'

function App() {
	let [array, setArray] = useState([])

	const addFunc = text => {
		if (text !== '') setArray([{ text, done: false, id: Date.now() }, ...array])
	}

	const deleteFunc = id => {
		setArray([...array].filter(x => x.id !== id))
	}

	return (
		<div>
			<div className='container'>
				<h1>Todos - simple react todo app</h1>
				<TaskInput addFunction={addFunc} />
				<TaskList tasks={array} deleteFunc={deleteFunc} />
			</div>
		</div>
	)
}

export default App
